package com.xiaoq.matrix.weixin;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import com.xiaoq.coms.util.WeixinXmlUtil;

@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class WXArticleMessage {
	@XmlElement(name = "ToUserName")
	@XmlJavaTypeAdapter(XmlCDATAAdapter.class)
	private String toUserName;

	@XmlElement(name = "FromUserName")
	@XmlJavaTypeAdapter(XmlCDATAAdapter.class)
	private String fromUserName;

	@XmlElement(name = "CreateTime")
	private Long createTime;

	@XmlElement(name = "MsgType")
	@XmlJavaTypeAdapter(XmlCDATAAdapter.class)
	private String msgType;

	@XmlElement(name = "Content")
	@XmlJavaTypeAdapter(XmlCDATAAdapter.class)
	private String content;

	@XmlElement(name = "MsgId")
	private String msgId;
	
	@XmlElement(name = "ArticleCount")
	private Integer articleCount; 
	
	@XmlElement(name = "item")
	@XmlElementWrapper(name="Articles")
	private List<Article> articles;
	
	
	
	public String getToUserName() {
		return toUserName;
	}



	public void setToUserName(String toUserName) {
		this.toUserName = toUserName;
	}



	public String getFromUserName() {
		return fromUserName;
	}



	public void setFromUserName(String fromUserName) {
		this.fromUserName = fromUserName;
	}



	public Long getCreateTime() {
		return createTime;
	}



	public void setCreateTime(Long createTime) {
		this.createTime = createTime;
	}



	public String getMsgType() {
		return msgType;
	}



	public void setMsgType(String msgType) {
		this.msgType = msgType;
	}



	public String getContent() {
		return content;
	}



	public void setContent(String content) {
		this.content = content;
	}



	public String getMsgId() {
		return msgId;
	}



	public void setMsgId(String msgId) {
		this.msgId = msgId;
	}



	public Integer getArticleCount() {
		return articleCount;
	}



	public void setArticleCount(Integer articleCount) {
		this.articleCount = articleCount;
	}



	public List<Article> getArticles() {
		return articles;
	}



	public void setArticles(List<Article> articles) {
		this.articles = articles;
	}



	public static void main(String[] argv) {
		WXArticleMessage respMsg = new WXArticleMessage();
		respMsg.setArticleCount(1);
		respMsg.setMsgType("news");
		respMsg.setCreateTime(System.currentTimeMillis()/1000);
		respMsg.setFromUserName("gh_ceb3d35356a0");
		respMsg.setToUserName("oMa-7wGC52wg_U-wMxu9RcI9TDaM");
		List<Article> articles = new ArrayList<Article>();
		Article article = new Article();
		article.setDescription("图文信息描述");
		article.setPicUrl("https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png");
		article.setUrl("www.baidu.com");
		articles.add(article);
		respMsg.setArticles(articles);
		System.out.println(WeixinXmlUtil.asXml(respMsg));
	}
}
